<?php

class YAMLDomDefinition
{

  public static function fromFile($file)
  {
    if (! sy_path_is_absolute($file)) {
      $file = Simplify::getConfig()->get('app_dir') . '/model/' . $file;
    }

    $s = Syml::read($file);

    $domain = Domain::getInstance();

    foreach ($s['objects'] as $name => $def) {
      $domain->addDefinition('object', $name, $def);
    }

    if (! empty($s['repositories'])) {
      foreach ($s['repositories'] as $name => $def) {
        $domain->addDefinition('repository', $name, $def);
      }
    }
  }

}

?>